home *** CD-ROM | disk | FTP | other *** search
- Path: mudskipper.cac.psu.edu!user
- From: fcusack@tdx.org (frank.)
- Newsgroups: comp.lang.c
- Subject: Re: simple code, argc, argv, strcmp()
- Date: Sat, 03 Feb 1996 19:02:11 -0400
- Organization: Penn State University, Center for Academic Computing
- Message-ID: <fcusack-0302961902110001@mudskipper.cac.psu.edu>
- References: <11f7cc$17261a.3b3@daprez> <4etj7c$bma@news.iag.net> <fcusack-0202961621470001@mudskipper.cac.psu.edu> <4f0rjn$sfh@news.iag.net>
- NNTP-Posting-Host: mudskipper.cac.psu.edu
-
- In article <4f0rjn$sfh@news.iag.net>, jatmon@iag.net (John R Buchan) wrote:
-
- > In article <fcusack-0202961621470001@mudskipper.cac.psu.edu>, fcusack@tdx.org
- > says...
- > >
- > >In article <4etj7c$bma@news.iag.net>, jatmon@iag.net (John R Buchan) wrote:
- > >
- > >> In article <11f7cc$17261a.3b3@daprez>, otisg@panther.middlebury.edu says...
- > >> >
- > <snip>
- [..]
- > >> >
- > >> > if (!strcmp(argv[1],"-d") || !strcmp(argv[1],"-e")) {
- > >> > Usage();
- > >> > }
- > >> <snip>
- > >>
- > >> I assume you mean this to call Usage if argv[1] is not "-e" and not "-d"?
- > >> Change the || to &&.
- > >
- > >The && test would _never_ pass. argv[1] could never be both "-d" and "-e".
- >
- > You are correct, of course. Stupidity on my part. I tend to get careless
- > about strcmp's reverse logic (ie returns False, when the strings match), when
- > I am not paying attention (not an excuse, just an explanation). I normally
- > compare the return value to 0, just to keep myself straight.
- >
-
- I hate strcmp also. c++ shines here, you can just overload ==.
-
- > >The || is correct here.
- > <snip>
-
- This is of course wrong though. I always have a hard time with strcmp...
-
- >
- > if ( strcmp(argv[1],"-d") && strcmp(argv[1],"-e") )
-
- much better. :)
- ~Frank
- -- I am Pentium of Borg. Division is futile. You will be approximated. --
- -- If you build it, they will come --> http://www.tdx.org/~fcusack/ --
- -- PGP key fingerprint: 01 C0 C0 B9 CC 78 67 0F 3F 64 80 65 8B 0F F9 EA --
-